import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementUI from 'element-ui' // 引入ElementUi
import 'element-ui/lib/theme-chalk/index.css'
import './style/style.css'
import axios from 'axios'
import service from './utils/request'
import VueWechatTitle from 'vue-wechat-title'

Vue.prototype.axios = axios // 挂载到原型，可在全局使用
Vue.prototype.service = service // service 挂载到原型，可在全局使用
Vue.config.productionTip = false
Vue.prototype.$bus = new Vue()
Vue.use(ElementUI) // 使用 ElementUi
Vue.use(VueWechatTitle) // 修改 title

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')

Vue.filter('formatDateTime', function (originVal: string | number | Date) {
  const date = new Date(originVal)
  const y = date.getFullYear()
  const m = '0' + (date.getMonth() + 1)
  const d = '0' + date.getDate()
  const h = (date.getHours() + '').padStart(2, '0')
  const mm = (date.getMinutes() + '').padStart(2, '0')
  const ss = (date.getSeconds() + '').padStart(2, '0')
  return `${y}-${m.substring(m.length - 2, m.length)}-${d.substring(d.length - 2, d.length)} ${h}:${mm}:${ss}`
})

Vue.filter('formatDate', function (originVal: string | number | Date) {
  const date = new Date(originVal)
  const y = date.getFullYear()
  const m = '0' + (date.getMonth() + 1)
  const d = '0' + date.getDate()
  return `${y}-${m.substring(m.length - 2, m.length)}-${d.substring(d.length - 2, d.length)}`
})